<template>
<div>
    <el-form>
<el-input  id="52" placeholder="Text field" v-model.trim="value">
<el-button slot="append" icon="el-icon-search" @click="handleSubSearch"></el-button> 
</el-input>
        <el-dialog :visible.sync="dialogVisible" width="80%">
        <el-row class="button-row">
          <el-col :span="9">
            <el-form-item id="71" label="用户代码" prop="userCode">
              <el-input :disabled="formDisabled" id="72"
                placeholder="Text field" v-model.trim="form_data.userCode">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item id="72" label="用户名称" prop="userName">
              <el-input :disabled="formDisabled" id="52"
                placeholder="Text field" v-model.trim="form_data.userName">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item id="73" label="域用户名" prop="adAcct">
              <el-input :disabled="formDisabled" id="52"
                placeholder="Text field" v-model.trim="form_data.adAcct">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item id="74" label="机构" prop="parentId">
                <orgSelect v-model="form_data.orgId"></orgSelect>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-button icon="el-icon-info" id="53" size="small"
              type="primary" v-on:click="onButtonClick53(form_data)">查询</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-table :data="table_data._data_list_" border highlight-current-row  @current-change="handleCurrentChange"
              id="50" max-height="500" ref="tableMain" stripe
              style="width: 100%">
              <el-table-column label="Actions" prop="action"
                type="selection"
                v-if="table_items.showHeader.indexOf('Actions') > -1" width="180"/>
              <el-table-column label="用户名" prop="leaderName"
                v-if="table_items.showHeader.indexOf('用户名') > -1" width="180"/>
              <el-table-column label="岗位" prop="posName"
                v-if="table_items.showHeader.indexOf('岗位') > -1" width="180"/>
              <el-table-column label="机构" prop="orgName"
                v-if="table_items.showHeader.indexOf('机构') > -1" width="180"/>
              <el-table-column label="Actions" prop="action" v-if="table_items.showHeader.indexOf('Actions') > -1"/>
            </el-table>
            <el-pagination :current-page.sync="form_data.pageNum"
              :page-size.sync="form_data.pageSize"
              :total="form_data.pageTotal" id="page50"
              layout="total, sizes, prev, pager, next, jumper"
              v-on:current-change="lastQuery(form_data)" v-on:size-change="val => { form_data.pageSize = val; lastQuery(form_data)}"/>
          </el-col>
        </el-row>
        </el-dialog>
    </el-form>
        </div>






</template>

<script>
import global_ from '@/common/Global'
import {doRequestPost,doRequestGet, doRequestPut, doRequestDel} from '@/utils/request'
import orgSelect from '@/components/Custom/OrgSelect'
export default {
    components: {
        orgSelect
    },
    created() {
        var self = this
        self.lastQuery(self.form_data)
    },
    props: {
        value: {
            type: String
        }
    },
    data() {
        return {
            dialogVisible: false,
            form_data: {
                parentId: '',
                userCode: '',
                userName: '',
                orgId: '',
                PageInfo: {
                    PageNum: 1,
                    PageSize: 10,
                    Total: 0
                }
            },
            table_data: {
                _data_list_: []
            },
            table_items:{
                showHeader:['用户名', '岗位', '机构']
            },
            selection: '',
            lock: 0
        }
    },
    methods: {
        getTableData(data) {
            var self = this
            doRequestPost(global_.rest_path + '/auth/api/user/getPositions', data).then( (res) => {
                //self.table_data._data_list_ = res.data.results
                self.table_data._data_list_ = res.Data
                self.form_data.PageInfo.Total = res.PageInfo.Total
            })

        },
        handleSubSearch() {
            var self = this
            self.dialogVisible = true
        },
        lastQuery(data) {
            var self = this
            self.getTableData(data)
        },
        handleCurrentChange(val) {
            var self = this
            self.selection = val 
            self.value = self.selection.uposId
            self.$emit('input', self.selection.uposId)
        },
        onButtonClick53(data) {
            this.lastQuery(data)
         }
    },
    mounted() {
    }
}

</script>